<template>
  <div ref="editor" class="dialog_detail"></div>
</template>
<script>
import E from 'wangeditor'
export default {
  props: {
    content: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // 富文本编辑html内容
      editor: ''
    }
  },
  mounted() {
    const editor = new E(this.$refs.editor)
    this.editor = editor
    this.editor.config.placeholder = ''
    this.editor.config.menus = ['head', 'bold', 'italic', 'underline', 'strikeThrough', 'justify']
    // 取消默认全屏
    this.editor.config.showFullScreen = false
    // editor.create()
    this.editor.config.onchange = function (newHtml) {
      if(newHtml == '<p><br/></p>'){
        newHtml = ''
      }
      this.$emit('greetA', newHtml)
      this.$emit('greetB', newHtml)
    }.bind(this)

    this.editor.create()
    this.editor.txt.html(this.content)
  }
}
</script>
